<!DOCTYPE html>
<html>
<head> 
	<title>My Papers List</title>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<link rel="stylesheet" href="__ROOT__/public/static/layui/css/layui.css" media="all">
	<script src="__ROOT__/public/static/layui/layui.js" charset="utf-8"></script> 
	<script type="text/javascript" src="__ROOT__/public/static/jquery-3.4.1.min.js"></script> 
</head>
<body>
	<ul class="layui-nav" lay-filter="header">
		<li class="layui-nav-item"><a href="firstPageInfo">首页信息</a></li>
		<li class="layui-nav-item layui-this" ><a href="mypapers">试卷分析列表</a></li>
		<li class="layui-nav-item" ><a href="myinfo">我的信息</a></li> 
    <li class="layui-nav-item layui-layout-right" >____工号:{$gh}____</li> 
	</ul>


<div>
<table id="paperlist"  class="layui-table" lay-data="{width: 892, height:330}" lay-filter="paperlist">
 
</table></div>
<div style="text-align: center;">
  <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" style="border-radius: 8px" onclick="newreport()" >新  增</button>
</div>

<script type="text/javascript">
  function newreport() {
    
    window.location.href='newreport';
  }
</script>
<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
 
<script>
	layui.use('table', function(){
		var table = layui.table;  
    table.render({
      elem:'#paperlist',
      url:'getpaperlist',
      method:'get',
      page:true,
      cols:[[
      {type:'numbers',title:'序号', align:'center',width:80},
      {field:'papercode',title:'试卷（课程）编号', width:280},
      {field:'reportaddress', title:'下载地址',width:180,templet:function(d){if(d.reportaddress=='已生成')return '<a id="downloadaddress" style="color: #F40" href="'+"__ROOT__/public/targetxls/"+d.papercode+'.xls" download="'+d.papercode+'.xls">点我下载</a>';else return d.reportaddress;}},
      {field:'step1',align:'center',  title:'1',width:50,templet:function(d){if(d.step1=='X') return "<img src=__ROOT__/public/img/c.png>"; else return "<img src=__ROOT__/public/img/d.png>";}},
      {field:'step2',align:'center', title:'2',width:50,templet:function(d){if(d.step2=='X') return "<img src=__ROOT__/public/img/c.png>"; else return "<img src=__ROOT__/public/img/d.png>";}},
      {field:'step3',align:'center', title:'3',width:50,templet:function(d){if(d.step3=='X') return "<img src=__ROOT__/public/img/c.png>"; else return "<img src=__ROOT__/public/img/d.png>";}},
      {field:'step4',align:'center', title:'4',width:50,templet:function(d){if(d.step4=='X') return "<img src=__ROOT__/public/img/c.png>"; else return "<img src=__ROOT__/public/img/d.png>";}},
      {field:'step5',align:'center', title:'5',width:50,templet:function(d){if(d.step5=='X') return "<img src=__ROOT__/public/img/c.png>"; else return "<img src=__ROOT__/public/img/d.png>";}},
      {field:'step6',align:'center', title:'6',width:50,templet:function(d){if(d.step6=='X') return "<img src=__ROOT__/public/img/c.png>"; else return "<img src=__ROOT__/public/img/d.png>";}},
      {fixed:'right',title:'操作', width:150, align:'center', toolbar: '#barDemo'}
      ]],
      parseData:function(res) {
        var t=JSON.parse(res);
        // console.log(t.data);
        return {
          "code":0,
          "msg":"good",
          "count":t.count,
          "data":t.data
        };
      }
    });






  //监听工具条
  table.on('tool(paperlist)', function(obj){
  	var data = obj.data;
  	if(obj.event === 'del'){
  		layer.confirm('真的删除行么', function(index){
  		  jQuery.ajax({
            type:"POST",
            contentType:"application/json;charset=UTF-8",
            url:"{$baseurl}/index.php/index/index/deletepaperbyid/paperid/"+data.id,
            // data:{paperid:data.id},
            beforeSend:function(){
              console.log(this.data);
              layer.msg('正与服务器联系......');
            },
            success:function (result) {
              var x=JSON.parse(result);
              if (x.result==1) {
                obj.del();
                layer.close(index);
                layer.msg('删除成功！');
              }else{
                layer.msg('删除失败！');
              }
            }
          });



  		});
  	} else if(obj.event === 'edit'){
  		window.location.href="{:url('index/index/newreport')}"+'?paperid='+data.id;
  	}
  }); 
});
</script>          




	<script>
		layui.use(['layer','element'], function(){
  var element = layui.element; //导航的hover效果、二级菜单等功能，需要依赖element模块
  //监听导航点击
  element.on('nav(header)', function(elem){
    // console.log(elem)
    // layer.msg(elem.text());
});
});
</script>
<div class="layui-footer" style="margin-bottom: 0px;position:fixed;  bottom:0px;">
 卷面数据分析应用程序 Copyright © 2020 Math HZNU. All rights reserved.
</div>
</body>
</html>